package cn.com.higinet.dl.joa.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.com.higinet.dl.joa.dao.SimpleDao;
import cn.com.higinet.dl.joa.service.SystemService;
@Service("systemService")
public class SystemServiceImpl implements SystemService{
	
	@Autowired
	private SimpleDao joaSimpleDao;

	public SimpleDao getJoaSimpleDao() {
		return joaSimpleDao;
	}

	public void setJoaSimpleDao(SimpleDao joaSimpleDao) {
		this.joaSimpleDao = joaSimpleDao;
	}

	@Override
	public List<Map<String, Object>> getAllSearch(Map<String, Object> reqs, HttpServletRequest request) {
		// TODO Auto-generated method stub
		Map<String, Object> map = new HashMap<String, Object>();
		int page = Integer.parseInt(request.getParameter("page"));
		int min = 9 * (page - 1);
		int offset = 9;
		String text = reqs.get("text").toString();
        String sql = "select * from tp_topic where text = \""
					+ text
					+ "\" order by createTime Asc limit "
					+ min
					+ ","
					+ offset;
		
		//Map<String, Object> params = new HashMap<String, Object>();
		//params.put(null, null);
		//params.put("userType", userType);
		//return joaSimpleDao.queryForList(sql, params);
        List<Map<String, Object>> list = joaSimpleDao
				.queryForList(sql, map);
		return list;
	}
	/*@Override
	public List<Map<String, Object>> getGoodsByPriceAsc(
			Map<String, Object> reqs, HttpServletRequest request) {
		// TODO Auto-generated method stub
		String commodity_type2 = reqs.get("goods").toString();
		String commodity_sex = reqs.get("sex").toString();
		Map<String, Object> map = new HashMap<String, Object>();
		int page = Integer.parseInt(request.getParameter("page"));
		int min = 9 * (page - 1);
		int offset = 9;
		if (commodity_sex.equals("0")) {
			String sql = "select * from commodity_info where commodity_type2 = \""
					+ commodity_type2
					+ "\" order by commodity_price Asc limit "
					+ min
					+ ","
					+ offset;
			List<Map<String, Object>> list = joaSimpleDao
					.queryForList(sql, map);
			return list;
		} else {
			String sql = "select * from commodity_info where commodity_type2 = \""
					+ commodity_type2
					+ "\"and commodity_sex =\""
					+ commodity_sex
					+ "\" order by commodity_price Asc limit "
					+ min + "," + offset;
			List<Map<String, Object>> list = joaSimpleDao
					.queryForList(sql, map);
			return list;
		}
	}*/
}
